Skip to content

fix: fallback adapters report the active instance's model/provider - #6690

Open
Fyko wants to merge 3 commits into
livekit:mainfrom
petsinc:fallback-adapter-model-labels
Open

fix: fallback adapters report the active instance's model/provider#6690
Fyko wants to merge 3 commits into
livekit:mainfrom
petsinc:fallback-adapter-model-labels

Conversation

@Fyko

@Fyko Fyko commented Aug 3, 2026

Copy link
Copy Markdown

What

Adds a metrics_metadata property to the STT/TTS/LLM/RealtimeModel base classes (returns own model/provider), overridden by the fallback adapters to report the instance that most recently served a request. The three lk.agents.turn.* label sites in agent_activity.py now read it. Adapter model/provider stay "FallbackAdapter"/"livekit" for spans, logs, and error events.

Why

Turn histograms labeled from the top-level component collapse into one model_name="FallbackAdapter" series with a fallback adapter — you can't tell your primary's ttfb from your fallback's. Discussed with the LiveKit team in slack; surfacing the actual provider was agreed on. Scoped to metrics_metadata per @longcw's review, keeping the adapter's own identity stable everywhere else.

Semantics: the primary before any traffic, the last instance to produce output after that. Recovery probes never relabel. Tests cover all four adapters, including probe-doesn't-relabel and fresh-session-resets-to-primary.

https://claude.ai/code/session_01AkHCx6Qfu5i2Z6h8Pa82gE

@Fyko
Fyko requested a review from a team as a code owner August 3, 2026 22:45
@CLAassistant

CLAassistant commented Aug 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

devin-ai-integration[bot]

This comment was marked as resolved.

def model(self) -> str:
return "FallbackAdapter"
"""The model of the instance that most recently served a request (the primary before any traffic).""" # noqa: E501
return self._active_instance.model

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nested llm_request span already carries the real gen_ai.request.model, so model can stay "FallbackAdapter".

The only gap is lk.agents.turn.*, whose labels come from MetricsReport at three sites (agent_activity:3380, :3385, :4457). Maybe add a single metrics_metadata property, read at those three sites, splits the histograms and keeps model, ErrorEvent, and the user_turn span stable.

if TYPE_CHECKING:
    from ..llm.chat_context import MetricsMetadata

@property
def metrics_metadata(self) -> MetricsMetadata:  # base classes return their own model/provider
    return self._active_instance.metrics_metadata

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, didn't know of that. good idea. updated in refactor: label turn metrics via metrics_metadata, keep adapter model…

@Fyko Fyko closed this Aug 7, 2026
@Fyko Fyko reopened this Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants